Skip to content

Instantly share code, notes, and snippets.

@sendbird-community
Created March 17, 2023 19:20
Show Gist options
  • Save sendbird-community/7bee38400d17b61eab960ea41fe567f1 to your computer and use it in GitHub Desktop.
Save sendbird-community/7bee38400d17b61eab960ea41fe567f1 to your computer and use it in GitHub Desktop.
prepare to gather the ticket details and call to Sendbird for the agent’s Sendbird credentials.
const collectDataToPassToModal = async () => {
//Get current user/agent's details for fetching Sendbird Credentials and passing to the calls modal.
const agentData = await client.data.get('loggedInUser'); //https://developers.freshdesk.com/v2/docs/data-methods/#loggedInUser
const ticketCreatorData = await client.data.get('contact'); //https://developers.freshdesk.com/v2/docs/data-methods/#contactAPI
//Any unique identifier from the agent can be used in Sendbird.
//Additionally, it would be possible at this point to create the user in Sendbird.
//Here we only fetch the user but you could try to fetch the user and if that fails create a new user using the server.js functions.
const sendbirdUser = await fetchSendbirdUserCredentials(agentData.loggedInUser.org_agent_id) //https://sendbird.com/docs/chat/v3/platform-api/user/listing-users/get-a-user#1-get-a-user
return {agentData, ticketCreatorData, sendbirdUser}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment