Closed bobbydc closed 3 years ago
Hey Bobby,
This is a good place to ask questions as it'll make the answers easier for other folks to find as well.
1) I think https://github.com/helpscout/helpscout-api-php/pull/193 is the PR you're referring to. This means that it'd be available for SDK users >= v2.4.0. To use it, you would specify the phone number alongside the Customer, like this:
$customer = new Customer();
$customer->addEmail('my-customer@company.com');
$customer->addPhone('1234567890');
$thread = new \HelpScout\Api\Conversations\Threads\CustomerThread();
$thread->setCustomer($customer);
$thread->setText('Test');
$conversation = new Conversation();
$conversation->setSubject('Testing the PHP SDK');
$conversation->setStatus('active');
$conversation->setType('email');
$conversation->setMailboxId($mailboxId);
$conversation->setCustomer($customer);
$conversation->setThreads(new Collection([
$thread,
]));
try {
$conversationId = $client->conversations()->create($conversation);
} catch (\HelpScout\Api\Exception\ValidationErrorException $e) {
var_dump($e->getError()->getErrors());
}
2) You're very close on this one. Using the approach you took, $customer->getPhones()
is what you're looking for and will provide you all the phone numbers associated with that Customer.
Ben, thanks so much! I was able to stumble around in the code and found the answer to #2 but #1 was still a question. Added this and tested and it works as expected.
Follow-up question, is there a way to add tags to a conversation up creation? Basically what this does but when the conversation is created vs after.
$client->conversations()->updateTags( $conversationId, [ $tags ] );
Great, I'm glad that was still helpful! Tags can't be added to a convo at the time of creation, just after. We're always here to help if you have any other questions.
Greatly appreciate all the hard work in this API. I'm very new to Help Scout and hoping to clarify a couple of things. Please redirect me to a more appropriate location to ask questions like this if needed.
I am trying to do 2 things. PHP 7.3 using the latest composer install.
I can successfully create a new ticket but would like to attach the users phone number upon ticket creation. I saw somewhere an update that allowed for that but nothing explaining how to do it. Currently I create the ticket, use email to find the contact and add the phone number. 3 API calls instead of 1. I am using "Create Conversation: Customer thread - as if the customer emailed in" as the basis for this.
The second thing is being able to retrieve the phone number using the customer id. I can pull the customer information but no idea how to retrieve just the phone number along with this data. I've built a connector to Twilio to send an SMS when a support person replies to a ticket. It works great as long as I can retrieve that number.
Something like this is what I was expecting but doesn't work. Any guidance would be much appreciated.
$customer = $client->customers()->get( $id ); $phone = $customer->getPhone().PHP_EOL;