I have created a script which has a button that when clicked will create a phone activity for the related callers contact within CRM.
The issue is that we also want the phone activity to contain the wrap up code selected for that call.
Is there a way we can store that variable within my created script or have a separate call that is trigger when the wrap up call is selected or when the call is done?
To make sure that I understand your question, is your desired workflow something like this?
Call gets to an agent.
At some point the agent hits "the button", creating information inside of your CRM.
Sometime later the agent finishes up the call and sets a wrap up code
At this point you want there to be an event fired for your script where you have access to the wrap up code and can send that information to your CRM. Would you only want this to happen if they have hit "the button"?
There's not anything you can do from within the script to accomplish this. You would need a post-processing service that uses analytics APIs to retrieve data for completed conversations and then makes an API call to your CRM system to update the record. This open source project could serve as a starting point for that kind of integration: https://github.com/MyPureCloud/open-data-exporter