{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":4906,"path":"conversational-interfaces/virtual-agent/create-profile-parser-action-apple.md","title":"Create a profile parser action for Apple Messages for Business","bundle":null,"doc_type":null,"release":"australia","body":"\n# Create a profile parser action for Apple Messages for Business\n\nCreate an action to parse the user information response and find the corresponding user on the ServiceNow® instance for Conversational Integration with Apple Messages for Business using the information provided here.\n\n## Before you begin\n\nRole required: admin\n\n## Procedure\n\n1.  Refer to the following procedure to create a new action. [Create an action in Workflow Studio](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/build-workflows/create-action.md).\n\n2.  In the Workflow Studio integration hub, set the **Input** field to `response_body (string)`.\n\n    \\[Omitted image \"flowdesigner-action.png\"\\] Alt text: Workflow Studio integration hub page, showing profile parser action with code snippet example.\n\n3.  You can use the following example script to help create your script for the action.\n\n    ```\n    (function execute(inputs, outputs) { \n        try { \n            var profile = JSON.parse(inputs.response_body); \n            var email = profile[0]['profile']['email']; \n            var user_sys_id = \"\"; \n            var result = { \n                \"auth_success\": false, \n                \"user_sys_id\": \"\" \n            }; \n            if (email) { \n                result['auth_success'] = true; \n                var userGr = new GlideRecord(\"sys_user\"); \n                userGr.addQuery(\"email\", email); \n                userGr.query(); \n                if (userGr.getRowCount() == 1) \n                    if (userGr.next()) \n                        user_sys_id = userGr.getUniqueValue(); \n    \n                result['user_sys_id'] = user_sys_id; \n            } \n            outputs.result = result; \n        } catch (e) { \n            gs.error(\"Error in Virtual Agent - Parse User Profile: \" + e.message); \n            throw e; \n        } \n    })(inputs, outputs);\n    ```\n\n4.  Set the **Output** field to the following:\n\n    ```\n    result = {  \n        \"auth_success\": false,  \n        \"user_sys_id\": \"1234\" \n        };\n    ```\n\n\n"}}