Skip to content

gramener/itchat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IT Chat

A Google Chat bot for IT Tickets on Zoho ServiceDesk Platform at Straive.

It answers questions based on the user's IT tickets.

To use it:

  1. Add "IT Chat - Straive" to your chat or space. Contact s.anand@gramener.com if this is not visible to you.
  2. DM it saying something, e.g. "@IT Chat - Straive Help". It'll share the status of your tickets.

Setup

Authentication flow

When the admin visits /token, they

https://accounts.zoho.com/oauth/v2/auth?response_type=code&client_id=$SDP_CLIENT_ID&scope=SDPOnDemand.requests.ALL&redirect_uri=https://itchat.straive.app/token&access_type=offline

When they log in, it will redirect them to /token with a ?code=$grant_token. Store the grant_token.

Using the code, send a request to:

curl -i https://accounts.zoho.com/oauth/v2/token \
  -X POST \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "code=$grant_token" \
  -d "grant_type=authorization_code" \
  -d "client_id=$CLIENT_ID" \
  -d "client_secret=$CLIENT_SECRET" \
  -d "redirect_uri=https://itchat.straive.app/token"

This returns a JSON object with keys access_token, refresh_token.

Store the access_token and refresh_token in Cloudflare KV "tokens" namespace.

When the token expires, use the refresh token to get a new access token:

curl https://accounts.zoho.com/oauth/v2/token \
  -X POST   \
  -H "Content-Type: application/x-www-form-urlencoded"  \
  -d "refresh_token=$refresh_token"  \
  -d "grant_type=refresh_token" \
  -d "client_id=$SDP_CLIENT_ID" \
  -d "client_secret=$SDP_CLIENT_SECRET" \
  -d "redirect_uri=https://itchat.straive.app/token"

Links:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published