This topic was automatically generated from Slack. You can find the original thread here.
Dillon Lara : I need help setting up the following workflow: anytime my twitter handle is mentioned on twitter it should create a ticket with gorgias
This topic was automatically generated from Slack. You can find the original thread here.
Dillon Lara : I need help setting up the following workflow: anytime my twitter handle is mentioned on twitter it should create a ticket with gorgias
Dylan Sather (Pipedream) : Welcome . First, in the trigger step of the workflow, choose the Twitter app and the Search Mentions trigger. You’ll want to enter your username, with the @ sign, as the Search Term. This will trigger the workflow each time you’re mentioned.
We don’t have a native Gorgias action for adding a ticket, but are you comfortable making your own HTTP requests? I’d recommend adding a new step to your workflow and choosing the Gorgias app, then add the step to Run Node.js code with Gorgias. This adds sample Node.js code to your workflow that makes a test request to Gorgias. This includes the email and API key you link when you click the Connect Gorgias button and link your credentials to the step. Then I’d recommend modifying the code in that step to make a POST request, passing the data that Gorgias requires in the Create a Ticket request.
Let me know if that helps, or if you have any other specific questions.
Pravin Savkar : Hi - you can also try copying and configuring this workflow:
For the Receiver Email, I just created a customer in Gorgias for “Twitter” and passed the associated email address. There may be other ways to do this as well — you can easily modify the code to test them out. I hope that helps!
Dillon Lara : Thanks and @UMT4G7E5P. I’ll take a look at this in the morning and let you know if I run into any issues!
Dillon Lara : I copied the workflow but am getting the following error. I tried checking the documentation here: Running asynchronous code but it looks like the return is using await.
Pravin Savkar : I’ll run a test to see if I can repro and get back to you.
Dillon Lara : I appreciate it !
Pravin Savkar : I think you may have a config error in your connected account. I can repro your workflow error if I enter the full base API URL provided by Gorgias (e.g., https://xxxxxxxxx.gorgias.com/api/) when connecting my account to Pipedream. You should only enter the domain ([xxxxxxxxx.gorgias.com](http://xxxxxxxxx.gorgias.com)). Can you give that a try? We don’t support editing connected accounts yet (that’s coming soon), but you can connect a new one.
Dillon Lara : checking
Dillon Lara : that update seemed to do the trick. Test ran successfully though I don’t see it in gorgias yet. I think it was set to update every 15 minutes so will check here in just a bit.
Dillon Lara : it appears to be pulling twitter mentions properly but not seeing anything hit our gorgias chat yet
Pravin Savkar : I’m seeing the same behavior right now. However, I believe tickets were created in their platform:
• The observability for steps.gorgias returns the response from the Gorgias API – that indicates the ticket was created
• I’m able to retrieve the tickets associated with my tests via their API (I tested some ticket IDs using this workflow: Get Gorgias ticket by ID - Pipedream)
That said, I’m not sure why they’re not showing up in their UI. I suggest either waiting to see if the issue resolves or reaching out to Gorgias support (it would probably be valuable to send them ticket IDs returned by their API that are not showing up). I hope that helps!
Pravin Savkar : I took another look at this and realized that the created_datetime for the ticket was being set to the date/time for the Tweet. Since the date/time was in the past, the tickets were not showing up at the top of the list in Gorgias. I updated the workflow to set created_datetime to the date/time that the event is processed on Pipedream and that appears to resolve the issue (the tickets now appear at the top of the list as soon as the workflow runs):
"created_datetime": steps.trigger.context.ts,
I updated the code in the workflow I shared. Note: I commented out the message_id for testing so I could replay Tweets and create multiple tickets for testing (the API throws an error if a duplicate value is passed for that field). You can leave it commented out or uncomment it based on your needs. I hope that helps!
Dillon Lara : you da man! I’ll take a look here shortly.
Pravin Savkar : Try commenting out the last line:
"message_id": `${steps.trigger.event.id_str}
//"message_id": `${steps.trigger.event.id_str}
Pravin Savkar : The Gorgias API throws an error if it detects a duplicate ID
Dillon Lara : ahh that makes sense now
Pravin Savkar : Here’s my updated code for that step:
return await require("@pipedreamhq/platform").axios(this, {
url: `https://${auths.gorgias.domain}/api/tickets/`,
method: `post`,
auth: {
username: `${auths.gorgias.email}`,
password: `${auths.gorgias.api_key}`,
},
data: {
messages: [
{
"receiver":{
"email": params.receiver_email
},
"source": {
"from": {
"address": steps.trigger.event.user.screen_name,
"name": steps.trigger.event.user.name
},
"extra": steps.trigger.event.id_str
},
"via": "twitter",
"subject": `Twitter Mention from @${steps.trigger.event.user.screen_name}`,
"body_text": `${steps.trigger.event.full_text} https://twitter.com/${event.user.screen_name}/statuses/${event.id_str}`,
"channel": "twitter",
"created_datetime": steps.trigger.context.ts,
"external_id": steps.trigger.event.id_str,
"from_agent": false,
//"message_id": `${steps.trigger.event.id_str}`
}
]
}
})
Dillon Lara : ok it appears to have run. not seeing it in gorgias yet but will check again here in a bit.